//import hasthi.common.Utils;
//import hasthi.common.constants.WSDMConstants.SystemState;
//
//public class ManagedServiceSimulator {
//    static final double servicefailureProb = 0.01; 
//    int newReqCount;
//    int failedRequestCount;
//    int sucessfulRequestCount;
//    int pendingRequestsCount;
//    long lastRequestProcessingTime;
//    long maxRequestTime;
//    long lastRequestReceived;
//    String systemStatus;
//
//    public boolean update() {
//        newReqCount = 10 * (int) Math.abs(r.nextGaussian());
//        lastRequestReceived = System.currentTimeMillis() - 10 * (int) Math.abs(r.nextGaussian());
//        for (int i = 0; i < newReqCount; i++) {
//            if (Utils.selectWithProbability(0.1f)) {
//                failedRequestCount++;
//            } else {
//                sucessfulRequestCount++;
//            }
//            lastRequestProcessingTime = (long) Math.abs(r.nextGaussian()) + 10;
//            if (lastRequestProcessingTime > maxRequestTime) {
//                maxRequestTime = lastRequestProcessingTime;
//            }
//        }
//        pendingRequestsCount = pendingRequestsCount + (r.nextBoolean() ? +1 : -1) * r.nextInt(5);
//        if (Utils.selectWithProbability(servicefailureProb / 120f)) {
//            shutDown();
//            return false;
//        }
//        Thread.sleep(30000);
//
//        if (pendingRequestsCount > 200) {
//            systemStatus = "SaturatedState";
//        } else if (pendingRequestsCount > 0) {
//            systemStatus = "BusyState";
//        } else {
//            systemStatus = "IdleState";
//        }
//    }
//}
